package org.zhzh.crawler;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.zhzh.crawler.pageprocessor.BTHeavenPageProcessor;
import org.zhzh.crawler.pipeline.BTHeavenPipeline;

import us.codecraft.webmagic.Spider;

@SpringBootApplication
public class Application implements CommandLineRunner {

	@Autowired
	private BTHeavenPipeline btHeavenPipeline;

	@Autowired
	private BTHeavenPageProcessor btHeavenPageProcessor;

	@Override
	public void run(String... args) throws Exception {
		String url = "http://www.bttt.la/?PageNo=1";
		Spider.create(btHeavenPageProcessor).addPipeline(btHeavenPipeline).addUrl(url).thread(5).run();
	}

	public static void main(String[] args) {
		SpringApplication.run(Application.class, args);
	}

}
